package com.zhouyu;

import china.MakerApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportAware;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.MergedAnnotation;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Map;

@Configuration
@Import({MakerApplication.class, MakerApplication.Maker.class, MakerApplication.MakerComponent.class, Jerry.class})
//@Import(Test2.class)
public class Tom  {
	public Tom(){
 	}

 public String helloWorld(  ) throws Exception {
//		if (true) throw new Exception("出问题了");
		System.out.println("========>>Hello Wrold!!");
		return "Hello World!!";
	}


		public static void main(String[] args) throws IOException {
			SimpleMetadataReaderFactory simpleMetadataReaderFactory = new SimpleMetadataReaderFactory();

			// 构造一个MetadataReader
			MetadataReader metadataReader = simpleMetadataReaderFactory.getMetadataReader("com.zhouyu.AppConfig");

			System.out.println(metadataReader.getResource());

			// 得到一个ClassMetadata，并获取了类名
			ClassMetadata classMetadata = metadataReader.getClassMetadata();
			System.out.println(classMetadata.getClassName());


			// 获取一个AnnotationMetadata，并获取类上的注解信息
			AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
			for (String annotationType : annotationMetadata.getAnnotationTypes()) {
				System.out.println(annotationType);
			}
			for (MergedAnnotation<Annotation> annotation : annotationMetadata.getAnnotations()) {
				System.out.println(annotation + "-------");
			}

		}




}
